// 测试页面配置
export interface TestPage {
  name: string
  title: string
  description: string
  category: '综合' | 'UI组件' | '功能' | '数据'
  route: string
  icon?: string
  tags?: string[]
}

// 所有测试页面配置
export const testPages: TestPage[] = [
  {
    name: 'TestPage',
    title: '综合测试页面',
    description: '包含按钮组件、流式加载、防抖测试、数据库连接等综合测试',
    category: '综合',
    route: '/test/comprehensive',
    tags: ['按钮', '加载', '防抖', '数据库']
  },
  {
    name: 'TestSearchPage',
    title: '搜索功能测试',
    description: '测试搜索功能、搜索建议、搜索结果展示等',
    category: '功能',
    route: '/test-search',
    tags: ['搜索', '建议', '结果']
  },
  {
    name: 'TestFormPage',
    title: '表单组件测试',
    description: '测试Input、Textarea、Select等表单组件的样式和功能',
    category: 'UI组件',
    route: '/test-form',
    tags: ['表单', '输入', '选择器']
  },
  {
    name: 'TestSelectPage',
    title: '选择器组件测试',
    description: '测试Select组件的各种变体和功能',
    category: 'UI组件',
    route: '/test-select',
    tags: ['选择器', '下拉', '多选']
  },
  {
    name: 'TestTabPage',
    title: '标签页组件测试',
    description: '测试TabGroup组件的标签页切换功能',
    category: 'UI组件',
    route: '/test-tab',
    tags: ['标签页', '切换', '分组']
  },
  {
    name: 'TestUserPage',
    title: '用户功能测试',
    description: '测试用户相关功能，包括用户资料、评论等',
    category: '功能',
    route: '/test-user',
    tags: ['用户', '资料', '评论']
  },
  {
    name: 'TestRealDataPage',
    title: '真实数据测试',
    description: '使用真实数据库数据进行测试',
    category: '数据',
    route: '/test-real-data',
    tags: ['数据', '数据库', '真实数据']
  },
  {
    name: 'TestAwardsPage',
    title: '奖项功能测试',
    description: '测试电影奖项相关功能',
    category: '功能',
    route: '/test-awards',
    tags: ['奖项', '电影', '评选']
  },
  {
    name: 'TestLoadingPage',
    title: '加载状态测试',
    description: '测试各种加载状态和动画效果',
    category: 'UI组件',
    route: '/test-loading',
    tags: ['加载', '动画', '状态']
  },
  {
    name: 'TestDemoPage',
    title: '演示测试页面',
    description: '这是一个简单的演示测试页面，用于验证测试系统是否正常工作',
    category: '综合',
    route: '/test-demo',
    tags: ['演示', '验证', '系统']
  }
]

// 获取所有测试页面
export const getAllTestPages = (): TestPage[] => {
  return testPages
}

// 按分类获取测试页面
export const getTestPagesByCategory = (category: TestPage['category']): TestPage[] => {
  return testPages.filter(page => page.category === category)
}

// 按标签搜索测试页面
export const searchTestPagesByTag = (tag: string): TestPage[] => {
  return testPages.filter(page => 
    page.tags?.some(t => t.toLowerCase().includes(tag.toLowerCase())) ||
    page.title.toLowerCase().includes(tag.toLowerCase()) ||
    page.description.toLowerCase().includes(tag.toLowerCase())
  )
}

// 获取所有分类
export const getAllCategories = (): TestPage['category'][] => {
  const categories = new Set(testPages.map(page => page.category))
  return Array.from(categories)
}

// 获取所有标签
export const getAllTags = (): string[] => {
  const tags = new Set<string>()
  testPages.forEach(page => {
    page.tags?.forEach(tag => tags.add(tag))
  })
  return Array.from(tags).sort()
}

// 添加新的测试页面（用于开发时动态添加）
export const addTestPage = (testPage: TestPage): void => {
  // 检查是否已存在
  const existingIndex = testPages.findIndex(page => page.name === testPage.name)
  if (existingIndex >= 0) {
    testPages[existingIndex] = testPage
  } else {
    testPages.push(testPage)
  }
}

// 移除测试页面
export const removeTestPage = (name: string): void => {
  const index = testPages.findIndex(page => page.name === name)
  if (index >= 0) {
    testPages.splice(index, 1)
  }
}
